﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using JKF.DataModule.IDAL;

namespace JKF.DataModule.SqlServerDAL
{
    /// <summary>
    /// 数据访问类dalFEEDBACK。
    /// </summary>
    public partial class dalFEEDBACK : IdalFEEDBACK
    {
        private const string FieldShow = "FEEDBACK_KEY,TITLE ,FEEDBACKER ,convert(char(10),[FEEDBACK_DATE],120) FEEDBACK_DATE,IS_REPLIED,SHOP_CODE,isnull(FILE_PATH,'') FILE_PATH  ";
        private const string FieldOrder = "FEEDBACK_DATE DESC";
        private const string FieldKey = "FEEDBACK_KEY";

        public DataTable GetFeedBacks(string title,string status,string type
         ,string userKey, int pageCurrent, int pageSize, ref int pageCount, ref int rowCount)
        {
            var sql = new StringBuilder(@"  1=1 ");
            if (!string.IsNullOrEmpty(title))
            {
                sql.AppendFormat(" AND TITLE  like '%{0}%'", title);
            }

            if (!string.IsNullOrEmpty(type))
            {
                sql.AppendFormat(" AND type  = '{0}'", type);
            }            

            if (!string.IsNullOrEmpty(status))
            {
                sql.AppendFormat(" AND IS_REPLIED = '{0}'", status);
            }

            sql.AppendFormat(" AND USER_KEY = '{0}'",userKey);
            return DataPage.GetPageInfo("V_FEEDBACK", FieldKey, pageCurrent, pageSize, FieldShow, FieldOrder, sql.ToString(), ref pageCount, ref rowCount).Tables[0];
        }
    }
}
